package thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:DELL
 * Date:2024-12-18
 * Time:23:58
 */
//创建一个类，继承Thread
class MyThread extends Thread{
    @Override
    public void run() {
        //这个方法就是线程的入口方法
        while (true){
            System.out.println("hello thread");
            try {
                Thread.sleep(10000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
//创建线程
public class Demo1 {
    public static void main(String[] args) throws InterruptedException {
        Thread t=new MyThread();
        //start和run都是Thread的成员
        t.start();
        //t.run();
        while (true){
            System.out.println("hello main");
            Thread.sleep(10000);
        }
    }
}
